{% extends 'base.html' %}
{% block body %}
<div class="row">
    <div class="span10">
        <div>
            <h1 style="text-align:center">科室管理</h1><br/>
            <form style="width: 300px;" action="/Organization/deptCreate/" method="post">
                <input type="text" name="L_deptCreate" style="margin-bottom:0" title="发什么呆 ? ? 快填 ! ! " required="required" placeholder="请输入您要增加的科室">
                <button type="submit">增加</button>
            </form>
            <form style="width: 300px; position: absolute; top: 152px; right: 363px" action="/Organization/deptQuery/" method="post">
                <input type="text" name="L_deptQuery" style="margin-bottom:0" required="required" placeholder="请输入您要查询的科室">
                <button type="submit">查询</button>
            </form>
            <table class="table table-hover">
                <thead>
		            <tr>
			            <th style="width:33%;text-align:center">ID</th>
			            <th style="width:33%;text-align:center">科室</th>
			            <th style="width:33%;text-align:center">操作</th>
		            </tr>
	            </thead>
	            <tbody>
                    {% for d in L_deptList %}
		                <tr>
			                <td style="text-align:center">{{ d.id }}</td>
			                <td style="text-align:center">{{ d.deptName }}</td>
			                <td style="text-align:center"><a data-toggle="modal" data-target="#myModal{{ d.id }}">修改</a>
                                <div class="modal fade" id="myModal{{ d.id }}" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	                                <div class="modal-dialog">
		                                <div class="modal-content">
			                                <div class="modal-header">
				                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				                                <h4 class="modal-title" id="myModalLabel">修改科室名称</h4>
			                                </div>
                                            <form action="/Organization/deptUpdate/{{ d.id }}/" method="post">
			                                    <div class="modal-body">
				                                    <input type="text" name="L_deptUpdate" required="required" placeholder="请输入科室名称">
			                                    </div>
			                                    <div class="modal-footer">
                                                    <button type="button" data-dismiss="modal">关闭</button>
                                                    <button type="submit">提交更改</button>
                                                </div>
                                            </form>
		                                </div><!-- /.modal-content -->
	                                </div><!-- /.modal -->
                                </div>
                                    &nbsp;
                                <a onclick="delDept({{ d.id }})">删除</a>
                            </td>
		                </tr>
                    {% endfor %}
	            </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}
{% block script %}
    function delDept(id){
        a = confirm('确定删除此部门?');
        if (a){
            location.href="http://localhost:8000/Organization/deptRemove/"+id;
        }
    }
{% endblock %}
